<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>

    <script type="text/javascript">


        function setXMLHttpRequest() {
            var xhr = null;
            // browser standard con supporto nativo
            if (window.XMLHttpRequest) {
                xhr = new XMLHttpRequest();
            }


            // MSIE 6 con ActiveX
            else if (window.ActiveXObject) {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            return xhr;
        }
        
        var xhrObj = setXMLHttpRequest();


        function resultHandler(c) {
            var url = "ajaxServlet?myVar=" + c;

            xhrObj.open("GET", url, true);
            xhrObj.onreadystatechange = updatePage;
            xhrObj.send(null);
            return;
        }

        function updatePage() {

            var risp = xhrObj.responseText;

            document.getElementById("resu").value = risp;

        }
    </script>



    <body>
        <div>TODO write content</div>
        <br>
        <br>

        <!--form name="input" action="ajaxServlet" method="get"-->
        Username: <input type="text" name="user" onchange="resultHandler(this.value);
                return true;">
        Server said: <input type="text" id="resu">
        <!--input type="submit" value="Submit">
    </form--> 



    </body>
</html>
